home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / lib / FileSys.sig < prev    next >
Encoding:
Text File  |  1997-08-18  |  5.9 KB  |  146 lines  |  [TEXT/Moml]

  1. (* OS.FileSys -- SML Basis Library *)
  2.  
  3. type dirstream
  4. datatype access = A_READ | A_WRITE | A_EXEC
  5.  
  6. val openDir   : string -> dirstream
  7. val readDir   : dirstream -> string
  8. val rewindDir : dirstream -> unit
  9. val closeDir  : dirstream -> unit
  10.  
  11. val chDir     : string -> unit
  12. val getDir    : unit -> string
  13. val mkDir     : string -> unit
  14. val rmDir     : string -> unit
  15. val isDir     : string -> bool
  16.  
  17. val realPath  : string -> string
  18. val fullPath  : string -> string
  19. val isLink    : string -> bool
  20. val readLink  : string -> string
  21.  
  22. val modTime   : string -> Time.time
  23. val setTime   : string * Time.time option -> unit
  24. val remove    : string -> unit
  25. val rename    : {old: string, new: string} -> unit
  26. val access    : string * access list -> bool
  27. val fileSize  : string -> int
  28.  
  29. val tmpName   : unit -> string
  30.  
  31. eqtype file_id;
  32. val fileId    : string -> file_id
  33. val hash      : file_id -> word
  34. val compare   : file_id * file_id -> order
  35.  
  36. (* These functions operate on the file system.  They raise OS.SysErr
  37.    in case of errors.
  38.  
  39.    [openDir p] opens directory p and returns a directory stream for
  40.    use by readDir, rewindDir, and closeDir.  Subsequent calls to
  41.    readDir will return the directory entries in some unspecified
  42.    order.
  43.  
  44.    [readDir dstr] returns and consumes a file name from the directory
  45.    stream.  If the directory stream is empty (all entries have been
  46.    read), then the empty string "" is returned.
  47.  
  48.    [rewindDir dstr] resets the directory stream as if it had just been
  49.    opened.
  50.  
  51.    [closeDir dstr] closes the directory stream.  All subsequent
  52.    operations on the stream will raise OS.SysErr.
  53.  
  54.    [chDir p] changes the current working directory to p.  This affects
  55.    calls to the functions use, load, compile in the interactive
  56.    system, as well as all functions defined in this library.  If p
  57.    specifies a volume name, then this command also changes the current
  58.    volume (relevant under DOS, Windows, OS/2, etc.).  
  59.  
  60.    [getDir ()] returns the name of the current working directory.
  61.  
  62.    [mkDir p] creates directory p on the file system.
  63.  
  64.    [rmDir p] removes directory p from the file system.
  65.  
  66.    [isDir p] tests whether p is a directory.
  67.  
  68.    [fullPath p] returns a canonical form of path p, where all
  69.    occurrences of the arcs ".", "..", "" have been expanded or
  70.    removed, and (under Unix) symbolic links have been fully expanded.
  71.    Raises SysErr if a directory on the path, or the file or directory
  72.    named, does not exist or is not accessible, or if there is a link
  73.    loop.
  74.  
  75.    [realPath p] behaves as fullPath(p) if p is absolute.  If p is
  76.    relative and on the same volume as the current working directory,
  77.    it returns a canonical path relative to the current working
  78.    directory, where superfluous occurrences of the arcs ".", "..", ""
  79.    have been removed, and (under Unix) symbolic links have been fully
  80.    expanded.  Raises SysErr if a directory on the path, or the file or
  81.    directory named, does not exist or is not accessible, or if there
  82.    is a link loop.  Raises Path if p is relative and on a different
  83.    volume than the current working directory.
  84.  
  85.    [isLink p] returns true if p names a symbolic link.  Raises SysErr
  86.    if the file does not exist or there is an access violation.  On
  87.    operating systems without symbolic links, it returns false, or
  88.    raises SysErr if the file does not exist or there is an access
  89.    violation.
  90.  
  91.    [readLink p] returns the contents of the symbolic link p.  Raises
  92.    SysErr if p does not exist or is not a symbolic link, or there is
  93.    an access violation.  On operating systems without symbolic links,
  94.    it raises SysErr.
  95.  
  96.    [modTime p] returns the modification time of file p.
  97.  
  98.    [setTime (p, tmopt)] sets the modification and access time of file
  99.    p.  If tmopt is SOME t, then the time t is used; otherwise the
  100.    current time, that is, Time.now(), is used.
  101.  
  102.    [remove p] deletes file p from the file system.
  103.  
  104.    [rename {old, new}] changes the name of file `old' to `new'.
  105.  
  106.    [access (p, accs)] tests the access permissions of file p,
  107.    expanding symbolic links as necessary.  If the list accs of
  108.    required access permission is empty, it tests whether p exists.  If
  109.    accs contains A_READ, A_WRITE, or A_EXEC, respectively, it tests
  110.    whether the user process has read, write, or execute permission for
  111.    the file.  
  112.        Under Unix, the access test is done with the `real' user
  113.    id and group id (as opposed to the `effective' user id and group
  114.    id) of the user process.  Hence access("file", [A_READ]) may return
  115.    false, yet the file may be readable by the process, in case the
  116.    effective user id or group id has been changed by setuid.
  117.  
  118.    [fileSize p] return the size, in bytes, of the file p.  Raises SysErr 
  119.    if p does not exist or its directory is not accessible.
  120.  
  121.    [tmpName ()] returns a file name suitable for creating a fresh
  122.    temporary file.  Note that there is no guarantee that the file name
  123.    will be unique, since a file of that name may be created between
  124.    the call to tmpName and a subsequent call to openOut which creates
  125.    the file.  The file name will be absolute, usually of the form
  126.    /tmp/xxxxxxxx provided by POSIX tmpnam (3).
  127.  
  128.    [file_id] is the type of unique identities of file system objects
  129.    (including device ids and volume ids, but possibly insensitive to
  130.    volume changes on removable volumes, such as tapes and diskettes).
  131.    The set of file ids is equipped with a total linear order.
  132.  
  133.    [fileId p] returns the file_id of the file system object named by
  134.    path p.  It holds that fileId p1 = fileId p2 if and only if p1 and
  135.    p2 name the same file system object.
  136.    
  137.    [hash fid] returns a hashvalue for fid, suitable for use in a
  138.    hashtable of file ids (and hence files).  
  139.    If fid1 = fid2 then hash fid1 = hash fid2.
  140.  
  141.    [compare (fid1, fid2)] returns LESS, EQUAL, or GREATER, according
  142.    as fid1 precedes, equals, or follows fid2 in the total linear order
  143.    on file ids.  This is suitable for e.g. an ordered binary tree of
  144.    file ids (and hence files).  
  145. *)
  146.